package org.fing.edu.uy.esbadp.modules.admMonitoring;

import java.util.logging.Level;
import java.util.logging.Logger;

public class AdmMonitoringThread extends Thread {
	
	private static final java.util.logging.Logger logger = Logger.getLogger(AdmMonitoringThread.class.getSimpleName());
	
	private boolean isAlive = true;
	private long timeSleep;
	
	public AdmMonitoringThread(long timeSleep){
		this.timeSleep = timeSleep;
	}
	
	public void stopSafe() {
		isAlive = false;
    }
	
	@Override
	public void run(){
		while(isAlive){
			try{
				 logger.info("The thread is sleeping...");
				
				 Thread.sleep(this.timeSleep);
				 
				 logger.info("The thread is running...");
				 
				 MonitoringAdministrator.getInstance().createPropertiesForServices();

			}catch (Exception ex) {
				logger.log(Level.SEVERE,"There was an error in the execution of the thread.", ex);
			}
		}
		logger.info("The thread AdmMonitoringThread was stopped correctly...");
	}
	
}
